
<?php include $this->admin_tpl('header'); ?>

<div class="content">
<div class="site"> <?php echo C('site_name')?> <a href="#">联盟商家</a> > 联盟商家添加 </div>
<span class="line_white"></span> 
<script type="text/javascript" src="/template/default/statics/js/area.js"></script>
<script>var ajaxurl = "<?php echo U('Union/getArea') ?>";</script>
<div class="install mt10">
  <dl>
    <dt><a href="<?php echo U('Union/index') ?>">联盟商家列表</a><a href="javascript:void(0)" class="hover">添加联盟商家</a></dt>
    <dd>
      <div class="install mt10">
        <dl>
          <form action="<?php echo U('Union/add') ?>" class="addform" method="post">
            <dd>
              <ul class="web">
                <li> <strong>商店名称：</strong>
                  <input type="text" class="text_input" name="company_name" value="<?php echo $info["company_name"];?>" placeholder='' datatype="*"/>
                  <span class="Validform_checktip ">请填写商店名称 </span> </li>
                <li style="line-height:24px;"> <strong>店铺图片：</strong> <b style="width:256px;">
                  <input value="<?php echo $info["company_logo"];?>" type="hidden" name="company_logo">
                  <img class="upimg" src="<?php echo IMG_PATH; ?>admin/input_9.png"> 
                  <?php if($info["company_logo"]!=""){?>
                  <span style="padding-left: 0px;"><img src="<?php echo $info["company_logo"];?>" height="43"></span>
                  <?php }?>
                  <span style="padding-left: 0px;"></span> </b><span>店铺图片</span> </li>
                <li>
                                        <strong>推荐：</strong>
                                        <select name="tuijian">
                                        	<option value="0" <?php if($info["tuijian"]==0){ echo ' selected="selected"';}?>>不推荐</option>
                                            <option value="1" <?php if($info["tuijian"]==1){ echo ' selected="selected"';}?>>一级推荐</option>
                                           <!-- <option value="2" <?php if($info["tuijian"]==2){ echo ' selected="selected"';}?>>二级推荐</option>
                                            <option value="3" <?php if($info["tuijian"]==3){ echo ' selected="selected"';}?>>三级推荐</option>-->
                                        </select>
                                        <span class="Validform_checktip" style="margin-left: 216px;">是否推荐</span>
                                    </li>
                <li> <strong>联系人：</strong>
                  <input type="text" class="text_input" name="realname" value="<?php echo $info["realname"];?>" placeholder=''  datatype="*"/>
                  <span class="Validform_checktip">请填写商店联系人</span> </li>
                <li> <strong>联系电话：</strong>
                  <input type="text" class="text_input" name="phone" value="<?php echo $info["phone"];?>" placeholder='' datatype="*"/>
                  <span class="Validform_checktip">请填写商店联系电话</span> </li>
                <li> <strong>商店地区：</strong>
                  <select name="province" id="province" onChange="loadArea(this.value, 'city')" style="height:40px;">
                    <option value="-1" selected>--请选择省份--</option>
                    <?php
                        foreach($region as $v){
						?>
                    <option value="<?php echo $v["area_id"]?>" <?php if($info["province"]==$v["area_id"]){?> selected="selected"<?php }?>><?php echo $v["area_name"]?></option>
                    <?php
							  }
						?>
                  </select>
                  <select name="city" id="city" onChange="loadArea(this.value, 'district')" style="height:40px;">
                    <option value="-1">--请选择城市--</option>
                     <?php
                       if($opt=="edit"){
						
                        foreach($city as $v){
						?>
                    <option value="<?php echo $v["area_id"]?>" <?php if($info["city"]==$v["area_id"]){?> selected="selected"<?php }?>><?php echo $v["area_name"]?></option>
                    <?php
							  }
							  }
						?>
                  </select>
                  <select name="district" id="district" onChange="loadArea(this.value, 'null')" style="height:40px;">
                    <option value="-1">--请选择地区--</option>
                    <?php
                       if($opt=="edit"){
						
                        foreach($district as $v){
						?>
                    <option value="<?php echo $v["area_id"]?>" <?php if($info["district"]==$v["area_id"]){?> selected="selected"<?php }?>><?php echo $v["area_name"]?></option>
                    <?php
							  }
							  }
						?>
                  </select>
                </li>
                <li> <strong>商店地址：</strong>
                  <input type="text" class="text_input" name="address" value="<?php echo $info["address"];?>" placeholder=''  datatype="*" />
                  <span class="Validform_checktip">请填写商店地址</span> </li>
                <li> <strong>经营范围：</strong>
                  <input type="text" class="text_input" name="business" value="<?php echo $info["business"];?>" placeholder=''  datatype="*"/>
                  <span class="Validform_checktip">请填写商店经营范围</span> </li>
                <li> <strong>行业分类：</strong><select name="fenlei" id="fenlei" style="height:40px;">
                    <?php
                              foreach($union_type as $v){
							  ?>
                    <option value="<?php echo $v["id"]?>" <?php if($info["fenlei"]==$v["id"]){?> selected="selected"<?php }?>><?php echo $v["type_name"]?></option>
                    <?php
							  }
										  ?>
                  </select>
                  <span class="Validform_checktip">请选择行业分类</span> </li>
              </ul>
              <div class="edit_box">
                  <strong class="edit">您正在编辑当前商家详细信息，默认所见即所得模式，您也可以点击HTML源码切换到代码模式进行编辑。</strong>
                  <div class="editor edit">
                      <?php echo form::editor('content',$info["content"]);?>
                  </div>
              </div>
				
              <div class="input1">
               <?php if(!empty($info)){ ?>
                            <input type="hidden" value="<?php echo $info['id'] ?>" name="id" />
                            <input type="hidden" value="edit" name="opt" />
                    	<?php }else{ ?>
                            <input type="hidden" value="add" name="opt" />
                        <?php }; ?>
                <input type="button" class="button_search "  id="btn_sub" value="提交" />
              </div>
            </dd>
          </form>
        </dl>
      </div>
    </dd>
  </dl>
</div>
<!--编辑器开始-->
<link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH; ?>Editor/themes/default/default.css">
<script type="text/javascript" src="<?php echo JS_PATH; ?>Editor/kindeditor-min.js"></script> 
<script type="text/javascript" src="<?php echo JS_PATH; ?>Editor/lang/zh_CN.js"></script> 
<script>
        $(function() {
        	//编辑器载入
			KindEditor.ready(function(K) {
				//K.create('#content');
				editor = K.editor({
                    uploadJson : '<?php echo U("Admin/Editor/upload?SSID=",'','');?>'+'<?php echo C("SSID");?>',
                	fileManagerJson : '<?php echo U("Admin/Editor/file_manage?parentdir=company_logo/",'','');?>',
                    extraFileUploadParams: {
                         PHPSESSID : '<?php echo session_id() ?>',
                         parentdir : 'company_logo/'
                    },
                    allowFileManager: true
                });
				//给按钮添加click事件
				$('.upimg').live('click', function() {
					var self = $(this);
					editor.loadPlugin('image', function() {
						//图片弹窗的基本参数配置
						editor.plugin.imageDialog({
							imageUrl: self.prev('input').val(), //如果图片路径框内有内容直接赋值于弹出框的图片地址文本框
							//点击弹窗内”确定“按钮所执行的逻辑
							clickFn: function(url, title, width, height, border, align) {
								self.prev("input").val(url);
								self.next("span").html("<img src=" + url + " height=43>");
								editor.hideDialog(); //隐藏弹窗
							}
						});
					});
				});
			});
           
        });
    </script> 
<script>
$(function() {
	var demo = $(".addform").Validform({
		btnSubmit: "#btn_sub",
		btnReset: ".btn_reset",
		tiptype: function(){},
		label: ".label",
		showAllError: false,
		ajaxPost: true,
		callback: function(data) {
			$("#Validform_msg").hide();
			if (data.status == 0) {
				art.dialog({width: 320, time: 5, title: '温馨提示(5秒后关闭)', content: data.info, ok: true});
			}
			if (data.status == 1) {
				window.location.href = data.url;
			}
		}
	});
});
</script>
<?php include $this->admin_tpl('copyright') ?>
